import { ApiProperty } from '@nestjs/swagger'
import {
  PrimaryGeneratedColumn,
  CreateDateColumn,
  UpdateDateColumn
} from 'typeorm'
import { randomUUID } from 'node:crypto'

export class BaseModels {
  @CreateDateColumn({
    default: () => "datetime('now', '+8 hour')",
    name: 'create_at',
    select: false,
    type: 'date'
  })
  createAt: string

  @UpdateDateColumn({
    default: () => "datetime('now', '+8 hour')",
    name: 'update_at',
    select: false,
    type: 'date'
  })
  updateAt: string
}

export class BaseModelsWithUUIDPrimary extends BaseModels {
  @ApiProperty({ name: 'id', example: 'id', description: 'id' })
  @PrimaryGeneratedColumn('uuid')
  id: string

  constructor() {
    super()
    this.id = randomUUID().replace(/-/g, '')
  }
}

export const NicknameList = [
  '胡迪',
  '提莫',
  '安迪',
  '牧羊',
  '巴斯',
  '安妮',
  '蜜桃',
  '凤梨',
  '雪糕',
  '柯南',
  '灰原',
  '步美',
  '元太',
  '光彦',
  '园子',
  '京极',
  '安室',
  '朱迪',
  '琴酒',
  '伏特加',
  '苦艾酒',
  '毛利兰',
  '上尉',
  '秋田',
  '逍遥'
]

export * from './Auth.entity'
export * from './Category.entity'
export * from './Comment.entity'
export * from './Post.entity'
export * from './Role.entity'
export * from './Upload.entity'
export * from './User.entity'
